import request from '@/utils/request.js'

/**
 *  封装请求用户频道列表文章的方法
 * @param {*} params {}
 * @returns  promise
 */

export const getChannelArticleAPI = (params) => {
  return request({
    url: '/v1_1/articles',
    params
  })
}

/**
 * 根据id获取文章详情
 * @param {*} id 文章id
 * @returns promise
 */
export const getArticleDetailsAPI = (id) => {
  return request({
    url: '/v1_0/articles/' + id
  })
}

/**
 * 根据用户id关注用户
 * @param {*} target 用户id
 * @returns promise
 */
export const userFollowAPI = (target) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 根据用户id取消关注
 * @param {*} target 用户id
 * @returns promise
 */
export const deleteUserFollowAPI = (target) => {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}

/**
 * 收藏文章
 * @param {*} target 文章id
 * @returns promise
 */
export const collectArticleAPI = (target) => {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 取消收藏文章
 * @param {*} target 文章id
 * @returns promise
 */
export const removeArticleAPI = (target) => {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}

/**
 * 获取评论列表
 * @param {*} params
 * @returns promise
 */
export const getCommentListAPI = (params) => {
  return request({
    url: '/v1_0/comments',
    params
  })
}

/**
 * 提交评论
 * @param {*} data 提交评论所需要的数据 {}
 * @returns promise
 */
export const postCommentAPI = (data) => {
  return request({
    url: '/v1_0/comments',
    method: 'POST',
    data
  })
}
